package com.fuluwa.interfaces.init.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fuluwa.infra.web.AbstractDomainController;
import com.fuluwa.infra.web.Result;
import com.fuluwa.interfaces.init.facade.InitService;

@Controller
@RequestMapping(value = "/init")
public class InitController  extends AbstractDomainController{
	@Autowired
	InitService initService;
	@RequestMapping(value = "db", method = RequestMethod.GET)
	@ResponseBody
	public Result database() {
		try {
			initService.doInit();
			return getSuccessResult();
		} catch (Exception e) {
			logger.error("error", e);
			return getFailResult("File upload Failed:" + e.getMessage());
		}
	}
	@RequestMapping(value = "index", method = RequestMethod.GET)
	@ResponseBody
	public Result index() {
		try {
			initService.doIndex();
			return getSuccessResult();
		} catch (Exception e) {
			logger.error("error", e);
			return getFailResult("File upload Failed:" + e.getMessage());
		}
	}
}
